﻿using System.Collections.Generic;
using System.ServiceModel;
using FastNET.CleanAct.Common.Contracts.DataContracts.Requests;
using FastNET.CleanAct.Common.Contracts.DataContracts.Responses;
using FastNET.CleanAct.Common.Contracts.ServiceContracts;
using FastNET.CleanAct.Common.EngineModel.Managers.Interface;
using FastNET.CleanAct.Common.Repository;

namespace FastNET.CleanAct.Client.ManagerEngine.ServiceHosts
{
    internal class ProcessingHost : ServiceHost, IProcessingServerContract
    {

        private readonly IServerDataManager _dataManager;

        public ProcessingHost(IServerDataManager dataManager)
        {
            _dataManager = dataManager;
        }


        /// <summary>
        /// Operation for retrieving a list of all schedules matching this client
        /// </summary>
        /// <returns>A <see cref="ResponseScheduleDataContract"/> with the response information</returns>
        public ResponseScheduleDataContract RetrieveSchedules()
        {
            return null;
        }

        /// <summary>
        /// Operation for retrieving processing information for an operation
        /// </summary>
        /// <param name="request">A <see cref="RequestProcessingInstructionsDataContract"/> with the request information</param>
        /// <returns>A <see cref="ResponseProcessingInstructionsDataContract"/> with the response information</returns>
        public ResponseProcessingInstructionsDataContract RetrieveProcessingInstructions(RequestProcessingInstructionsDataContract request)
        {
            ResponseProcessingInstructionsDataContract response = new ResponseProcessingInstructionsDataContract();

            IList<Identity> templateIDs = _dataManager.GetScheduleTemplates(new Identity(request.ScheduleID));

            response.ProcessingConfiguration = _dataManager.BuildInstructionSet(templateIDs);
            response.ProcessingGroup = "scan"; //For the time being we do not clean

            return response;
        }
    }
}
